<template>
	<view class="order-container" :data-theme="themeStyle">
		<view class="order-nav">
			<view v-for="(statusItem, statusIndex) in statusList" :key="statusIndex" class="uni-tab-item" :id="statusItem.id" :data-current="statusIndex" @click="ontabtap">
				<text class="uni-tab-item-title" :class="statusItem.status == orderStatus ? 'uni-tab-item-title-active color-base-border  color-base-text' : ''">
					{{ statusItem.name }}
				</text>
			</view>
		</view>

		<mescroll-uni ref="mescroll" @getData="getListData" top="100rpx">
			<block slot="list">
				<view class="order-list" v-if="orderList.length > 0">
					<view class="order-item" v-for="(orderItem, orderIndex) in orderList" :key="orderIndex">
						
						
						
						
						<view class="order-header" :class="{ waitpay: orderStatus == 'waitpay' && orderItem.order_status == 0 }">
							<view
								class="iconfont"
								:class="$util.inArray(orderItem.order_id, mergePayOrder) == -1 ? 'iconyuan_checkbox' : 'iconyuan_checked color-base-text'"
								@click="selectOrder(orderItem.order_id, orderItem.pay_money)"
								v-if="orderStatus == 'waitpay' && orderItem.order_status == 0"
							></view>
							<view class="iconfont icondianpu" @click="toShopDetail(orderItem.site_id)"></view>
							<text class="site-name" @click="toShopDetail(orderItem.site_id)">{{ orderItem.site_name }}</text>
							<view class="iconfont iconright" @click="toShopDetail(orderItem.site_id)"></view>
							<text class="status-name color-base-text">{{ orderItem.order_status_name }}</text>
						</view>
						<view class="order-body" @click="orderDetail(orderItem)">
							<view class="goods-wrap" v-for="(goodsItem, goodsIndex) in orderItem.order_goods" :key="goodsIndex">
								<view class="goods-img">
									<image
										:src="$util.img(goodsItem.sku_image, { size: 'mid' })"
										@error="imgError(orderIndex, goodsIndex)"
										mode="aspectFill"
										:lazy-load="true"
									></image>
								</view>
								<view class="goods-info">
									<view class="pro-info">
										<view class="goods-name">{{ goodsItem.sku_name }}</view>
										<view class="sku" v-if="goodsItem.sku_spec_format">
											<view class="goods-spec">
												<block v-for="(x, i) in goodsItem.sku_spec_format" :key="i">
													{{ x.spec_value_name }} {{ i < goodsItem.sku_spec_format.length - 1 ? '; ' : '' }}
												</block>
											</view>
										</view>
									</view>
									<view class="goods-sub-section">
										<text class="goods-price">
											<text class="unit color-base-text font-size-activity-tag">{{ $lang('common.currencySymbol') }}</text>
											<text class="color-base-text">{{ goodsItem.price }}</text>
										</text>
										<text class="goods-num">
											<text class="iconfont iconclose"></text>
											{{ goodsItem.num }}
										</text>
									</view>
									<text class="tip" v-if="goodsItem.is_present">赠品</text>
									<view class="goods-operation"></view>
								</view>
							</view>
						</view>
						<view class="order-footer">
							<view class="order-base-info">
								<view class="total">
									<text class="font-size-sub">共{{ orderItem.goods_num }}件商品</text>
									<text class="align-right font-size-base">
										实付款：
										<text class="font-size-base">{{ $lang('common.currencySymbol') }}{{ orderItem.pay_money }}</text>
									</text>
								</view>
							</view>
							
							<!-- <view class="order-action" v-if="currentId !=1"><view class="order-box-btn color-base-border color-base-text" @click="openInvoicePopup(siteItem)">开具发票</view></view> -->
							<!-- <view class="order-action" v-if="currentId !=1 && stateinvoice == false"><view class="order-box-btn color-base-border color-base-text" @click="openInvoicePopup(orderItem)">开具正票</view></view> -->
							<view class="order-action" v-if="orderItem.invoice_list.invoice_status == 0"><view class="order-box-btn color-base-border color-base-text" @click="openInvoicePopup(orderItem)">开具正票</view></view>
							<view class="order-action" v-if="orderItem.invoice_list.invoice_status == 1"><view class="order-box-btn color-base-border color-base-text" @click="openInvoicePopup(orderItem)">发票申请中</view></view>
							<view class="order-action" v-if="orderItem.invoice_list.invoice_status == 2"><view class="order-box-btn color-base-border color-base-text" @click="openInvoicePopup(orderItem)">开具红票</view></view>
							<view class="order-action" v-if="orderItem.invoice_list.invoice_status == 3"><view class="order-box-btn color-base-border color-base-text" @click="openInvoicePopup(orderItem)">开票完成</view></view>
							<!-- <view class="order-action" v-else><view class="order-box-btn color-base-border color-base-text" @click="openInvoicePopup(orderItem)">已开票</view></view> -->
							<view class="">
								
								<view class="order-action" v-if="orderItem.action.length > 0">
									<view
										class="order-box-btn"
										v-if="evaluateConfig.evaluate_status == 1 && orderItem.is_evaluate == 1 && (orderList.order_status == 4 || orderList.order_status == 10 )" 
										@click="operation('memberOrderEvaluation', orderItem)"
									>
										<text v-if="orderItem.evaluate_status == 0">评价</text>
										<text v-else-if="orderItem.evaluate_status == 1">追评</text>
									</view>
									<view
										class="order-box-btn"
										:class="{ 'color-base-border color-base-text': operationItem.action == 'orderPay' }"
										v-for="(operationItem, operationIndex) in orderItem.action"
										:key="operationIndex"
										@click="operation(operationItem.action, orderItem)"
									>
										{{ operationItem.title }}
									</view>
								</view>
								
								<view class="order-action" v-else-if="orderItem.action.length == 0 && orderItem.is_evaluate == 1 && evaluateConfig.evaluate_status == 1 && (orderList.order_status == 4 || orderList.order_status == 10 )">
									<view class="order-box-btn" v-if="orderItem.is_evaluate == 1" @click="operation('memberOrderEvaluation', orderItem)">
										<text v-if="orderItem.evaluate_status == 0">评价</text>
										<text v-else-if="orderItem.evaluate_status == 1">追评</text>
									</view>
								</view>
								
								<view class="order-action" v-else><view class="order-box-btn color-base-border color-base-text" @click="orderDetail(orderItem)">查看详情</view></view>
								
							
								
								
							</view>
							
							
						</view>
						
					</view>
				</view>
				<view v-else><ns-empty :isIndex="!1" :text="$lang('emptyTips')"></ns-empty></view>
			</block>
		</mescroll-uni>

		<view class="order-batch-action" :class="{ 'bottom-safe-area': isIphoneX }" v-if="mergePayOrder.length">
			<view class="action-btn color-base-text color-base-border" @click="openChoosePaymentMerge()">合并付款</view>
		</view>

		<!-- 选择支付方式弹窗 -->
		<ns-payment ref="choosePaymentPopup" :payMoney="payMoney" @confirm="pay"></ns-payment>
		<ns-payment ref="choosePaymentMergePopup" :payMoney="payMoneyMerge" @confirm="mergePay()"></ns-payment>

		<loading-cover ref="loadingCover"></loading-cover>
		
		
		
		<!-- 发票弹窗 -->
		<uni-popup ref="invoicePopup" type="bottom">
			<view style="height: ;" class="invoice-popup popup" @touchmove.prevent.stop>
				<view class="popup-header">
					<text class="tit">发票</text>
					<text class="iconfont iconclose" @click="closeInvoicePopup()"></text>
				</view>
				<scroll-view scroll-y="true" class="popup-body" :class="{ 'safe-area': isIphoneX }">
					<view>
							<view class="invoice-cell">
								<text class="tit">抬头类型</text>
								<view class="option-grpup">
									<view class="option-item" :class="{ 'color-base-bg active': orderInvoice.type == 1 }" @click="changeInvoiceTitleType2(1)">
										个人
									</view>
									<!-- <view class="option-item" :class="{ 'color-base-bg active': orderInvoice.invoice_title_type == 2 }" @click="changeInvoiceTitleType(1)"> -->
									<view class="option-item" :class="{ 'color-base-bg active': orderInvoice.type == 2 }" @click="changeInvoiceTitleType2(2)">
										企业
									</view>
								</view>
							</view>
							<view class="invoice-cell">
								<text class="tit">发票信息</text>
								<view class="invoice-form-group">
									<input type="text" placeholder="购方名称" v-model="orderInvoice.gfmc" @input="gfmc" />
									<input type="text" placeholder="购方税号(个人可不填,企业必填)" v-if="orderInvoice.type == 2" v-model.gfsh="orderInvoice.gfsh" @input="gfsh"/>
									<input type="text" maxlength="11" placeholder="购方手机号(用于接收开票成功短信)"  v-model.gfsj="orderInvoice.gfsj" @input="gfsj"/>
									<input type="text" placeholder="购方地址(个人可不填,企业必填)" v-if="orderInvoice.type == 2" v-model.gfdz="orderInvoice.gfdz" @input="gfdz"/>
									<input type="text" placeholder="购方电话(个人可不填,企业必填)" v-if="orderInvoice.type == 2" v-model.gfdh="orderInvoice.gfdh" @input="gfdh"/>
									<input type="text" placeholder="购方银行(个人可不填,企业必填)" v-if="orderInvoice.type == 2" v-model.gfyh="orderInvoice.gfyh" @input="gfyh"/>
									<input type="text" placeholder="购方账号(个人可不填,企业必填)" v-if="orderInvoice.type == 2" v-model.gfzh="orderInvoice.gfzh" @input="gfzh"/>
									<input type="text" placeholder="备注" v-model.bz="orderInvoice.bz" @input="bz"/>
									<input type="text" placeholder="请填写邮箱(必填)" v-model.gfemail="orderInvoice.gfemail" @input="gfemail"/>
								</view>	
								
							</view>
							<view class="invoice-cell">
								<!-- <view class="invoice-tips">发票内容将以根据税法调整，具体请以展示为准，发票内容显示详细商品名 称及价格信息</view> -->
								<view class="" style="display: flex;justify-content: space-around;margin-top: 10rpx;">
									<view class="invoice-tips" style="color: red;" @click="just">查看正票</view>
									<view class="invoice-tips" style="color: red;" @click="red">查看红票</view>
								</view>
								<view class="popup-footer"  @click="saveInvoice"  v-if="orderInvoice.invoice_status == 0"><view class="confirm-btn color-base-bg">开具正票</view></view>
								<view class="popup-footer"  @click="saveInvoiceRed" :class="{ 'bottom-safe-area': isIphoneX }" v-if="orderInvoice.invoice_status == 2"><view class="confirm-btn color-base-bg">开具红票</view></view>
							</view>
					</view>
				</scroll-view>
				
				
			</view>
		</uni-popup>
	</view>
</template>

<script>
import orderMethod from '../public/js/orderMethod.js';
import globalConfig from '@/common/js/golbalConfig.js';
import nsPayment from '@/components/payment/payment.vue';
import payment from '../public/js/payment.js';
// import pay from '../public/js/payment.js'

export default {
	data() {
		return {
			scrollInto: '',
			orderStatus: 'all',
			statusList: [],
			orderList: [],
			contentText: {},
			mergePayOrder: [],
			isIphoneX: false,
			evaluateConfig: {
				evaluate_audit: 1,
				evaluate_show: 0,
				evaluate_status: 1
			},
			orderData: {},
			payMoney: 0,
			payMoneyMerge: 0,
			orderInvoice: { //发票需要的参数
				// 新发票参数
				type:1,//1：个人、2：企业
				gfmc:'',//购方名称
				gfsh:'',//购方税号 企业必填,个人可为空
				gfsj:'',//购方手机 ( 开票成功会短信提醒购方)
				gfdz:'',//购方地址 企业必填,个人可为空
				gfdh:'',//购方电话 企业必填,个人可为空
				gfyh:'',//购方银行 企业必填,个人可为空
				gfzh:'',//购方账号 企业必填,个人可为空
				kplx:0,//开票类型: 0,正票 1,红票
				hzfpsqbbh:'',//红字发票申请表编号（红票必填）
				yfphm:'',//对应蓝票发票号码（红票必填）
				bz:'',//备注
				gfemail:'',//邮箱
				order_id:'',//商品id
			},
			currentId:0,//
			stateinvoice:false,//是否已经开票
		};
	},
	components: {
		nsPayment
	},
	mixins: [orderMethod, globalConfig],
	onLoad(option) {
		if (option.status) this.orderStatus = option.status;
	},
	onPageScroll(e) {
		// this.pageScrollTop = e.scrollTop;
		console.log('index333',this.pageScrollTop,e.scrollTop)
		// uni.setStorageSync('pageScrollTop', this.pageScrollTop);
	},
	onShow() {
		// 刷新多语言
		this.$langConfig.refresh();
		this.isIphoneX = this.$util.uniappIsIPhoneX();
		this.getEvaluateConfig();
		this.getOrderStatus();

		if (uni.getStorageSync('token')) {
			if (this.$refs.mescroll) this.$refs.mescroll.refresh();
		} else {
			this.$util.redirectTo('/pages/login/login/login', {
				back: '/pages/order/list/list?status=' + this.orderStatus
			});
		}
	},
	methods: {
		// 滚动
		scrolls(e){
			console.log('e')
		},
		// 显示弹出层
		openPopup(ref) {
			// if (ref == 'PlatcouponPopup') {
			// 	this.selectPlatCouponId = this.orderPaymentData.platform_coupon_id;
			// 	this.selectPlatCouponMoney = this.orderPaymentData.platform_coupon_money;
			// }
			this.$refs[ref].open();
			// this.$refs.popup.open()
		},
		// 关闭弹出层
		closePopup(ref) {
			if (this.tempData) {
				Object.assign(this.orderCreateData, this.tempData);
				Object.assign(this.orderPaymentData, this.tempData);
				this.tempData = null;
				this.$forceUpdate();
			}
			this.$refs[ref].close();
		},
		//打开发票弹窗
		openInvoicePopup(val) {
			
			console.log('idd999',val,val.order_id)
			
			this.orderInvoice = val.invoice_list
			this.orderInvoice.order_id = val.order_id
			console.log('打开发票弹窗',this.orderInvoice,this.orderInvoice.order_id)
			this.openPopup('invoicePopup');
			
		},
		// 切换发票开关-
		changeIsInvoice() {
			if (this.orderInvoice.is_invoice == 0) {
				this.orderInvoice.is_invoice = 1;
			} else {
				this.orderInvoice.is_invoice = 0;
			}
			this.$forceUpdate();
		},
		// 切换发票类型
		changeInvoiceType(invoice_type) {
			this.orderInvoice.invoice_type = invoice_type;
			this.$forceUpdate();
		},
		// 切换发票个人还是企业
		changeInvoiceTitleType2(invoice_title_type) {
			// this.orderInvoice.invoice_title_type = invoice_title_type;
			this.orderInvoice.type = invoice_title_type;
			console.log('个人还是企业发票',this.orderInvoice)
			this.$forceUpdate();
		},
		// 切换正票还是红票
		changeInvoiceTitleType3(kplx){
			this.orderInvoice.kplx = kplx;
			console.log('正票还是蓝票',this.orderInvoice.kplx)
			this.$forceUpdate();
		},
		//打印购方名称
		 gfmc(e){
			 this.orderInvoice.gfmc = e.detail.value
			console.log('gfmc111',e,this.orderInvoice.gfmc) 
		 },
		 gfsh(e){
			this.orderInvoice.gfsh = e.detail.value
		 },
		 gfsj(e){
			 this.orderInvoice.gfsj = e.detail.value
		 },
		 gfdz(e){
			 this.orderInvoice.gfdz = e.detail.value
		 },
		 gfdh(e){
			 this.orderInvoice.gfdh = e.detail.value
		 },
		 gfyh(e){
			 this.orderInvoice.gfyh = e.detail.value
		 },
		 gfzh(e){
			 this.orderInvoice.gfzh = e.detail.value
		 },
		 bz(e){
			 this.orderInvoice.bz = e.detail.value
		 },
		 gfemail(e){
			 this.orderInvoice.gfemail = e.detail.value
		 },
		// 选择发票内容
		changeInvoiceContent(invoice_content) {
			this.orderInvoice.invoice_content = invoice_content;
			this.$forceUpdate();
		},
		//关闭发票弹窗
		closeInvoicePopup() {
			this.$forceUpdate();
			this.$refs.invoicePopup.close();
		},
		// 发票验证
		invoiceVerify() {
			// if (this.orderInvoice.type == 1) {
				// if (this.orderInvoice.invoice_title == '') {
				if (this.orderInvoice.type == '') {
					this.$refs.invoicePopup.open();
					this.$util.showToast({
						title: "请选择发票抬头"
					});
					return false;
				}
				if (this.orderInvoice.gfmc == '') {
					this.$refs.invoicePopup.open();
					this.$util.showToast({
						title: "请填写购方名称"
					});
					return false;
				}
				if (this.orderInvoice.gfsh == '' && this.orderInvoice.type == 2) {
					this.$refs.invoicePopup.open();
					this.$util.showToast({
						title: "企业必填购方税号"
					});
					return false;
				}
				if (this.orderInvoice.gfsj == '') {
					this.$refs.invoicePopup.open();
					this.$util.showToast({
						title: "请填写购方手机（开票成功会短信提醒）"
					});
					return false;
				}
				if (this.orderInvoice.gfdz == '' && this.orderInvoice.type == 2) {
					this.$refs.invoicePopup.open();
					this.$util.showToast({
						title: "企业必填购方地址"
					});
					return false;
				}
				if (this.orderInvoice.gfdh == '' && this.orderInvoice.type == 2) {
					this.$refs.invoicePopup.open();
					this.$util.showToast({
						title: "企业必填购方电话"
					});
					return false;
				}
				if (this.orderInvoice.gfyh == '' && this.orderInvoice.type == 2) {
					this.$refs.invoicePopup.open();
					this.$util.showToast({
						title: "企业必填购方银行"
					});
					return false;
				}
				if (this.orderInvoice.gfzh == '' && this.orderInvoice.type == 2) {
					this.$refs.invoicePopup.open();
					this.$util.showToast({
						title: "企业必填购方账号"
					});
					return false;
				}
				// if (this.orderInvoice.kplx == '') {
				// 	this.$refs.invoicePopup.open();
				// 	this.$util.showToast({
				// 		title: "请选择开票类型"
				// 	});
				// 	return false;
				// }
				if (this.orderInvoice.hzfpsqbbh == '' && this.orderInvoice.kplx == 1) {
					this.$refs.invoicePopup.open();
					this.$util.showToast({
						title: "红字发票申请表编号（红票必填）"
					});
					return false;
				}
				if (this.orderInvoice.yfphm == '' && this.orderInvoice.kplx == 1) {
					this.$refs.invoicePopup.open();
					this.$util.showToast({
						title: "对应蓝票发票号码（红票必填）"
					});
					return false;
				}
				
				if (this.orderInvoice.gfemail == '') {
					this.$refs.invoicePopup.open();
					this.$util.showToast({
						title: "请填写邮箱类型"
					});
					return false;
				}
			// }
			// return true;
		},
		// 查看正票
		just(){
			let url = this.orderInvoice.pdfurl
			
			if(!url){
				uni.showToast({
					title:'还未开票成功',
					icon:'none'
				})
			}else{
				// uni.navigateTo({
				// 	url:'/otherpages/webview/webview?url=' + url
				// })
				
				uni.setClipboardData({
					data:this.orderInvoice.pdfurl,
					success() {
						uni.showModal({
							title:'复制成功，请到浏览器粘贴查看'
						})
					}
				})
				
			}
			
			
		},
		// 查看红票
		red(){
			let url = this.orderInvoice.red_pdfurl
			if(!url){
				uni.showToast({
					title:'还未开票成功',
					icon:'none'
				})
			}else{
				uni.setClipboardData({
					data:this.orderInvoice.red_pdfurl,
					success() {
						
						uni.showModal({
							content:"复制成功，请到浏览器粘贴查看"
						})
					}
				})
				// uni.navigateTo({
				// 	url:'/otherpages/webview/webview?url=' + url
				// })
			}
			
		},
		// 保存发票信息
		saveInvoice() {
			if(this.orderInvoice.bz == undefined){
				this.orderInvoice.bz = '开具发票'
			}
			if(this.orderInvoice.gfsh == undefined){
				this.orderInvoice.gfsh = ' '
			}
			this.$api.sendRequest({
				url:'/api/Invoice/save',
				data:{
					type:this.orderInvoice.type,
					gfmc:this.orderInvoice.gfmc,
					gfsh:this.orderInvoice.gfsh,
					gfsj:this.orderInvoice.gfsj,
					gfdz:this.orderInvoice.gfdz,
					gfdh:this.orderInvoice.gfdh,
					gfyh:this.orderInvoice.gfyh,
					gfzh:this.orderInvoice.gfzh,
					// kplx:this.orderInvoice.kplx,
					kplx:1,//正票
					hzfpsqbbh:this.orderInvoice.hzfpsqbbh,
					yfphm:this.orderInvoice.yfphm,
					bz:this.orderInvoice.bz,
					gfemail:this.orderInvoice.gfemail,
					order_id:this.orderInvoice.order_id,
				},
				success:res=>{
					let that = this
					console.log('发票保存成功')
					uni.showToast({
						title:res.message,
						icon:'none'
					})
					if(res.message == 'success'){
						that.stateinvoice = true
					}
				},
				faile:err=>{
					console.log('发票保存失败',err)
				}
			})
			if (this.invoiceVerify()) {
				// this.orderPaymentData.shop_goods_list[this.orderInvoice.site_id] = this.orderInvoice;
				// this.orderCalculate();
				this.closePopup('invoicePopup');
				
			}
			this.closePopup('invoicePopup');
			console.log('发票信息',this.orderInvoice)
		},
		// 开红票
		saveInvoiceRed(){
			
			this.$api.sendRequest({
				url:'/api/Invoice/red',
				data:{
					order_id:this.orderInvoice.order_id
				},
				success:res=>{
					let that = this
					console.log('开红票成功发票成功')
					uni.showToast({
						title:res.message,
						icon:'none'
					})
					if(res.message == 'success'){
						that.stateinvoice = true
					}
						// this.$refs[ref].close();
					
				},
				faile:err=>{
					console.log('开红票失败',err)
				}
			})
		},
		// 
		// 
		ontabtap(e) {
			console.log('eee111',e)
			let index = e.target.dataset.current || e.currentTarget.dataset.current;
			this.currentId = e.target.dataset.current || e.currentTarget.dataset.current;
			this.orderStatus = this.statusList[index].status;
			if (this.orderStatus == '') this.mergePayOrder = [];
			this.$refs.loadingCover.show();
			this.$refs.mescroll.refresh();
		},
		getListData(mescroll) {
			this.$api.sendRequest({
				url: '/api/order/lists',
				data: {
					page: mescroll.num,
					page_size: mescroll.size,
					order_status: this.orderStatus
				},
				success: res => {
					let newArr = [];
					let msg = res.message;
					if (res.code == 0 && res.data) {
						newArr = res.data.list;
					} else {
						this.$util.showToast({ title: msg });
					}
					mescroll.endSuccess(newArr.length);
					//设置列表数据
					if (mescroll.num == 1) this.orderList = []; //如果是第一页需手动制空列表
					this.orderList = this.orderList.concat(newArr); //追加新数据
					this.orderList.forEach(v => {
						v.order_goods.forEach(vo => {
							if (vo.sku_spec_format) {
								try {
									vo.sku_spec_format = JSON.parse(vo.sku_spec_format);
								} catch (e) {
									vo.sku_spec_format = vo.sku_spec_format;
								}
							} else {
								vo.sku_spec_format = [];
							}
						});
					});
					if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
				},
				fail: res => {
					mescroll.endErr();
					if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
				}
			});
		},
		/**
		 * 获取订单状态
		 */
		getOrderStatus() {
			this.statusList = [
				{
					status: 'all',
					name: this.$lang('all'),
					id: 'status_0'
				},
				{
					status: 'waitpay',
					name: this.$lang('waitPay'),
					id: 'status_1'
				},
				{
					status: 'waitsend',
					name: this.$lang('readyDelivery'),
					id: 'status_2'
				},
				{
					status: 'waitconfirm',
					name: this.$lang('waitDelivery'),
					id: 'status_3'
				},
				{
					status: 'waitrate',
					name: this.$lang('waitEvaluate'),
					id: 'status_4'
				}
			];
		},
		operation(action, orderData) {
			let index = this.status;
			switch (action) {
				case 'orderPay': // 支付
					this.orderData = orderData;
					this.payMoney = parseFloat(orderData.pay_money);
					this.orderPay(orderData);
					break;
				case 'orderClose': //关闭
					this.orderClose(orderData.order_id, () => {
						this.$refs.mescroll.refresh();
					});
					break;
				case 'memberTakeDelivery': //收货
					this.orderDelivery(orderData.order_id, () => {
						this.$refs.mescroll.refresh();
					});
					break;
				case 'trace': //查看物流
					this.$util.redirectTo('/pages/order/logistics/logistics', {
						order_id: orderData.order_id
					});
					break;
				case 'memberOrderEvaluation': //评价
					this.$util.redirectTo('/otherpages/order/evaluate/evaluate', {
						order_id: orderData.order_id
					});
					break;
				case 'extendTakeDelivery': //延长收回
					this.orderExtendTakeDelivery(orderData.order_id, () => {
						this.$refs.mescroll.refresh();
					});
					break;
			}
		},
		orderDetail(data) {
			console.log('详情data333',data)
			switch (parseInt(data.order_type)) {
				case 2:
					// 自提订单
					this.$util.redirectTo('/pages/order/detail_pickup/detail_pickup', {
						order_id: data.order_id
					});
					break;
				case 3:
					// 本地配送订单
					this.$util.redirectTo('/pages/order/detail_local_delivery/detail_local_delivery', {
						order_id: data.order_id
					});
					break;
				case 4:
					// 虚拟订单
					this.$util.redirectTo('/pages/order/detail_virtual/detail_virtual', {
						order_id: data.order_id
					});
					break;
				default:
					this.$util.redirectTo('/pages/order/detail/detail', {
						order_id: data.order_id
					});
					break;
			}
		},
		/**
		 * 选择订单
		 * @param {Object} orderId
		 */
		selectOrder(orderId, pay_money) {
			if (this.$util.inArray(orderId, this.mergePayOrder) != -1) {
				this.mergePayOrder.splice(this.$util.inArray(orderId, this.mergePayOrder), 1);
				this.payMoneyMerge -= parseFloat(pay_money);
			} else {
				this.payMoneyMerge += parseFloat(pay_money);
				this.mergePayOrder.push(orderId);
			}
		},
		/**
		 * 合并支付
		 */
		mergePay() {
			if (this.mergePayOrder.length) {
				this.$api.sendRequest({
					url: '/api/order/pay',
					data: {
						order_ids: this.mergePayOrder.toString()
					},
					success: res => {
						if (res.code >= 0) {
							this.$refs.choosePaymentMergePopup.getPayInfo(res.data);
						} else {
							this.$util.showToast({
								title: res.message
							});
						}
					}
				});
			}
		},
		toShopDetail(e) {
			this.$util.redirectTo('/otherpages/shop/index/index', { site_id: e });
		},
		imgError(orderIndex, goodsIndex) {
			this.orderList[orderIndex].order_goods[goodsIndex].sku_image = this.$util.getDefaultImage().default_goods_img;
			this.$forceUpdate();
		},
		getEvaluateConfig() {
			this.$api.sendRequest({
				url: '/api/goodsevaluate/config',
				success: res => {
					if (res.code == 0) {
						var data = res.data;
						this.evaluateConfig = data;
					}
				}
			});
		},
		// 显示选择支付方式弹框
		openChoosePayment() {
			this.$refs.choosePaymentPopup.open();
		},
		// 显示选择支付方式弹框【合并支付】
		openChoosePaymentMerge() {
			this.$refs.choosePaymentMergePopup.open();
		}
	},
	computed: {
		mpOrderList() {
			if (!this.orderList[this.status]) return;
			return this.orderList[this.status].list || [];
		}
	}
};
</script>

<style lang="scss">
@import '../public/css/list.scss';
@import './../../../common/css/order_parment.scss';
// @import './../../../common/css/order_parment.scss'
</style>
<style scoped>
/deep/ .uni-page {
	/* overflow: hidden; */
}
/deep/ .mescroll-upwarp {
	padding-bottom: 100rpx;
}
</style>
